<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="/static/css/pintuer.css">
<link rel="stylesheet" href="/static/css/admin.css">
<script src="/static/js/jquery.js"></script>
<script src="/static/js/pintuer.js"></script>
<script type="text/javascript">
	var aaa = $("#testlist").val();
	
	console.log(aaa)
</script>
</head>
<body>
<input type="hidden" id="testlist" value="111">
<form method="post" action="/user/selectUserByName?pageNum=1" id="listform">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder">用户列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
        <li> <a class="button border-main icon-plus-square-o" href="/user/toAddUser">添加用户</a> </li>
        <!-- <li> <a class="button border-main icon-plus-square-o" href="">批量添加用户</a> </li>  -->
        <li>
          <input type="text" placeholder="请输入搜索用户名" name="userName" class="input" style="width:250px; line-height:17px;display:inline-block" />
          <input class="button border-main icon-search" type="submit" value="搜索">
        </li>
      </ul>
    </div>
    <table class="table table-hover text-center">
      <tr>
        <!-- <th width="100" style="text-align:left; padding-left:20px;">ID</th> -->
        <th width="7%">姓名</th>
        <th width="15%">部门名称</th>
        <th width="15%">职位</th>
        <th width="13%">联系方式</th>
        <th width="10%">邮箱</th>
        <th width="10%">创建时间</th>
        <th width="30%">操作</th>
      </tr>
      <c:forEach items="${findUserList}" var="list">
        <tr>
        	<%-- <%=request.getAttribute("findUserList")%> --%>
        	<td id="idList" style="display: none">${list.id }</td>
			<td>${list.username}</td>
	        <td width="10%">${list.department.departmentname}</td>
	        <td>${list.position}</td>
	        <td>${list.phone}</td>
	        <td><font >${list.mail}</font></td>
	        <td>${list.createDate}</td>
	        <td>
		        <div class="button-group">
		        <c:if test="${list.isAdmin==0 }">
		        	<a  class="button border-green" href="/user/addAdmin?id=${list.id}&isAdmin=1"  ><span  class="icon-edit"></span>设为管理员</a>
		        </c:if>
		        <c:if test="${list.isAdmin==1 }">
		        	<a  class="button border-green" href="/user/addAdmin?id=${list.id}&isAdmin=0"><span  class="icon-edit"></span>取消管理员</a>
		        </c:if>
			        <a class="button border-main" href="/user/selectUserById?userId=${list.id}"><span class="icon-edit"></span> 修改</a> 
			        <a class="button border-red" href="/user/deleteUser?id=${list.id}" onclick="return del(1,1,1)"><span class="icon-trash-o"></span> 删除</a> 
		       </div>
	        </td>
		
        </tr>
        </c:forEach>
      <tr>
      	<td colspan="8">
      	<div class="pagelist">
      	<c:choose>
        <c:when test="${page.total <= 30}">
            <c:set var="begin" value="1"/>
            <c:set var="end" value="${page.total/5+1}"/>
        </c:when>
        <%--页数超过了6页--%>
        <c:otherwise>
            <c:set var="begin" value="${page.pageNum-1}"/>
            <c:set var="end" value="${page.total/5+1}"/>
            <%--如果begin减1后为0,设置起始页为1,最大页为6--%>
            <c:if test="${begin -1 <= 0}">
                <c:set var="begin" value="1"/>
                <c:set var="end" value="${page.total/5+1}"/>
            </c:if>
            <c:if test="${begin -1 <= 0}">
                <c:set var="begin" value="1"/>
                <c:set var="end" value="6"/>
            </c:if>
            <%--如果end超过最大页,设置起始页=最大页-5--%>
            <c:if test="${end > page.total}">
                <c:set var="begin" value="${page.total-5}"/>
                <c:set var="end" value="${page.total/5+1}"/>
            </c:if>
        </c:otherwise>
    </c:choose>
    <c:forEach var="i" begin="${begin}" end="${end}">
        <%--当前页,选中--%>
        <c:choose>
            <c:when test="${i == page.pageNum}">
                <span class="active"><a href="#">${i}</a></span>
            </c:when>
            <%--不是当前页--%>
            <c:otherwise>
                <span><a href="/user/findUserList?pageNum=${i}">${i}</a></span>
            </c:otherwise>
        </c:choose>
    </c:forEach>
    </div>
    </td>
        <!-- <td colspan="8"><div class="pagelist"> <a href="">上一页</a> <span class="current">1</span><a href="">2</a><a href="">3</a><a href="">下一页</a><a href="">尾页</a> </div></td> -->
      </tr>
    </table>
  </div>
</form>
<script type="text/javascript">

//搜索
function changesearch(){	
		
}

//单个删除
function del(id,mid,iscid){
	if(confirm("您确定要删除吗?")){
		
	}
}

//设置管理员
function add(){
    
} 


$("#checkall").click(function(){


 })

//全选
$("#checkall").click(function(){ 
  $("input[name='id[]']").each(function(){
	  if (this.checked) {
		  this.checked = false;
	  }
	  else {
		  this.checked = true;
	  }
  });
})

//批量删除
function DelSelect(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认要删除选中的内容吗？");
		if (t==false) return false;		
		$("#listform").submit();		
	}
	else{
		alert("请选择您要删除的内容!");
		return false;
	}
}

//批量排序
function sorts(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){	
		
		$("#listform").submit();		
	}
	else{
		alert("请选择要操作的内容!");
		return false;
	}
}


//批量首页显示
function changeishome(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		
		$("#listform").submit();	
	}
	else{
		alert("请选择要操作的内容!");		
	
		return false;
	}
}

//批量推荐
function changeisvouch(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		
		
		$("#listform").submit();	
	}
	else{
		alert("请选择要操作的内容!");	
		
		return false;
	}
}

//批量置顶
function changeistop(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){		
		
		$("#listform").submit();	
	}
	else{
		alert("请选择要操作的内容!");		
	
		return false;
	}
}


//批量移动
function changecate(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){		
		
		$("#listform").submit();		
	}
	else{
		alert("请选择要操作的内容!");
		
		return false;
	}
}

//批量复制
function changecopy(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){	
		var i = 0;
	    $("input[name='id[]']").each(function(){
	  		if (this.checked==true) {
				i++;
			}		
	    });
		if(i>1){ 
	    	alert("只能选择一条信息!");
			$(o).find("option:first").prop("selected","selected");
		}else{
		
			$("#listform").submit();		
		}	
	}
	else{
		alert("请选择要复制的内容!");
		$(o).find("option:first").prop("selected","selected");
		return false;
	}
}

</script>
</body>
</html>
